<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>admin</title>

    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="/static/css/admin/bootstrap.min14ed.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/font-awesome.min93e3.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/plugins/dataTables/dataTables.bootstrap.css">
	<link rel="stylesheet" type="text/css" href="/static/css/admin/animate.min.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/style.min862f.css"/>
    <link href="/static/css/admin/admincommon.css?v=20180712" rel='stylesheet' type='text/css' />
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>角色管理</h5>
                        <if condition="check_auth('admin/Role/addRoleAuth')">
                            <button id="toggle_modal" class="btn btn-primary btn-circle" type="button" style="margin-bottom:0px;margin-left:10px;position:relative;top:-5px;" title="添加角色">
                                <i class="fa fa-group"></i>+
                            </button>
                        </if>
                        <div class="ibox-tools">
                            <a href="javascript:location.replace(location.href);" class="btn btn-primary btn-circle" type="button" style="margin-bottom:0px;margin-right:10px;position:relative;top:-5px;" title="刷新">
                                <i class="fa fa-refresh"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>角色名</th>
                                    <th>描述</th>
                                    <th>加入时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <volist name="roles" id="vo">
                                    <tr class="gradeX" id="role-{$vo['role_id']}">
                                        <td>{$vo['role_id']}</td>
                                        <td>{$vo['role_name']}</td>
                                        <td>{$vo['role_describe']}</td>
                                        <td class="center">{$vo['role_add_time']}</td>
                                        <td class="center" align="center">
                                            <div class="btn-group">
                                                
                                                <if condition="$vo['role_id'] eq 1">
                                                    <if condition="$Request.session.user_id eq 1">
                                                        <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle" aria-expanded="false">操作 <span class="caret"></span>
                                                        </button>
                                                        <ul class="dropdown-menu">
                                                            <li>
                                                                <a href="javascript:;" class="font-bold edit-role" data-id="{$vo['role_id']}">修改</a>
                                                            </li>
                                                        </ul>
                                                    <else/>
                                                        <button data-toggle="dropdown" class="btn btn-primary btn-xs disabled" aria-expanded="false">操作 <span class="caret"></span>
                                                        </button>
                                                    </if>
                                                <else/>
                                                    <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle" aria-expanded="false">操作 <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu">
                                                        <if condition="check_auth('admin/Role/updateRoleAuth')">
                                                            <li><a href="javascript:;" class="font-bold edit-role" data-id="{$vo['role_id']}">修改</a></li>
                                                        </if>
                                                       
                                                        <if condition="check_auth('admin/Role/delRole')">
                                                            <li><a href="javascript:;" class="font-bold del-role" data-id="{$vo['role_id']}">删除</a></li>
                                                        </if>
                                                        
                                                    </ul>
                                                </if>
                                            </div>
                                        </td>
                                    </tr>
                                </volist>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <js href="/static/js/admin/jquery.min.js"/>
	<js href="/static/js/admin/bootstrap.min.js"/>
	<js href="/static/js/admin/plugins/dataTables/jquery.dataTables.js"/>
	<js href="/static/js/admin/plugins/dataTables/dataTables.bootstrap.js"/>
	<js href="/static/js/admin/content.min.js"/>
    <js href="/static/js/admin/plugins/layui/layer/layer.js"/>
    <script type="text/javascript" src="/static/js/admin/admincommon.js?v=20180712"></script>
    <script>
        $(document).ready(function(){
            $(".dataTables-example").dataTable();

            $(".ibox-content").on('click','.edit-role',function(){
                var roleId = $(this).data("id");
                var editIndex = layer.open({
                    title:'编辑角色',
                    offset: ['120px', '220px'],
                    isOutAnim: true ,
                    type: 2,
                    content:"{:url('admin/Role/roleAuth')}?type=update&role_id="+roleId,
                    area: ['800px','400px'],
                    maxmin: true
                });

                layer.full(editIndex);
            });
            
            $(".ibox-content").on('click','.del-role',function(){
                
                var roleId = $(this).data("id");

                layer.confirm("你确定要删除【"+$("#role-"+roleId).children("td").eq(1).text()+"】吗？", {

                    btn: ['确定','取消'] //按钮

                }, function(){

                    $.post("{:url('admin/Role/delRole')}",{role_id:roleId},function(data){
                    
                        if(data.code==1) {

                            layer.msg(data.msg, {time:500, icon:1});
                             
                            $("#role-"+roleId).remove();

                        }else{
                        
                            layer.msg(data.msg, {time:500, icon:2});

                        }

                    },'json');
                });
            });


            $("#toggle_modal").on('click',function(){

                var addIndex = layer.open({
                  title:'添加角色',
                  offset: ['120px', '220px'],
                  isOutAnim: true ,
                  type: 2,
                  content:"{:url('admin/Role/roleAuth')}?type=add",
                  area: ['800px','400px'],
                  maxmin: true
                });

                layer.full(addIndex);

            });
        }); 
        
    </script>

</body>
</html>